package org.airline.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import org.airline.dao.IOrderItemDao;
import org.airline.entity.OrderItem;
import org.airline.entity.PageBean;
import org.springframework.stereotype.Component;

@Component("OrderItemDaoImpl")
public class OrderItemDaoImpl extends HibernateDaoImpl implements IOrderItemDao {

	@Override
	public void deleteOrderItem(Long id) throws Exception {
		super.delete(OrderItem.class, id);
	}

	@Override
	public OrderItem getorderItemById(Long id) throws Exception {
		return (OrderItem)super.get(OrderItem.class, id);
	}

	@Override
	public PageBean queryForPage(int pageSize, int page) throws Exception {
		final String hql = "FROM OrderItem";
		return super.queryForPage(hql, pageSize, page);
	}

	@Override
	public void saveOrderItem(OrderItem orderItem) throws Exception {
		super.save(orderItem);
	}

	@Override
	public void updateOrderItem(OrderItem orderItem) throws Exception {
		super.update(orderItem);
	}
	
	@Override
	public PageBean queryForPageByKeyWords(int keyWord, int pageSize,
			int page) throws Exception {
		String hql = "FROM OrderItem WHERE isPayed = " + keyWord;
		return super.queryForPage(hql, pageSize, page);
	}

	@Override
	public PageBean queryForPageByUserId(int id, int pageSize, int page)
			throws Exception {
		final String hql = "FROM OrderItem WHERE user.id = " + id;
		return super.queryForPage(hql, pageSize, page);
	}

	
}
